 <!-- 学生管理
修改人：张家豪
时间：2020/6/22  -->
<template>
    <div class="about">

        <div>
            <el-form ref="searchForm" :model="searchForm" :inline="true" label-width="80px">
                <el-col :xl="6" :md="8" :sm="24">
                    <el-form-item label="课程名称" prop="nickname">
                        <el-input placeholder="请输入课程名称" v-model="searchForm.nickname" clearable></el-input>
                    </el-form-item>
                </el-col>

                <el-col :xl="6||24" :md="8||24" :sm="24">
                    <el-form-item>
                        <div :style=" { float: 'right', overflow: 'hidden' } || {} ">
                            <el-button icon="el-icon-search" type="primary" @click="search">搜索</el-button>
                            <el-button class="ml-5" icon="el-icon-refresh-left" @click="reset">重置</el-button>
                        </div>
                    </el-form-item>
                </el-col>
            </el-form>
        </div>
        <page-table @load-table-data="loadTableData" ref="dataTable" @selection-change="selection" row-key="id">
            <template slot="tb-columns">

                <el-table-column align="center" prop="nickname" label="学生姓名"></el-table-column>
                <el-table-column align="center" prop="grade" label="当前总分"></el-table-column>
                <el-table-column fixed="right" align="center" label="操作">
                    <template slot-scope="scope">
                        <!-- <el-button type="danger" @click="remove(scope.row.id)" v-if="scope.row.status==2" disabled
                            round>删除</el-button>
                        <el-button type="danger" @click="remove(scope.row.id)" v-else round>删除
                        </el-button> -->
                        <el-button type="primary" plain @click="workscore(scope.row)">查看作业</el-button>
                    </template>
                </el-table-column>

            </template>
        </page-table>
        <!-- 弹出添加的窗口 -->
        <Edit :visible='visible' :title='title' :defaultFormData='defaultFormData' v-if='visible' @close='close' />

    </div>
</template>



<script>
    import PageTable from '@/components/common/PageTable'
    import {pagestudent} from '@/api/modules/coursemanager'
    import Edit from '@/views/teacher/create_class/class_edit'
    // import About from './about'
    import {setCookie,getCookie} from '@/libs/cookie'
    export default {
        name: "manage_class",
        components: {
            PageTable,
            Edit
        },
        data() {

            return {
                searchForm: {
                    nickname: '',
                    courseId:''
                },
                multipleSelection: [],
                visible: false,
                username: '',
                defaultFormData: {},
                user:{},
                course:{
                    courseID:''
                }
            };
        },

        mounted(){
              let courseID = JSON.parse(getCookie("courseID") || '{}');
                this.searchForm.courseId = courseID.courseID
        },
        methods: {
            //课程中心
            workscore(row){
                setCookie('workInfor',row)
                let workInfor = JSON.parse(getCookie("workInfor") || '{}');
                // console.log("1")
                //console.log(workInfor)
                this.navigator('/work/score');
            },

            close(val) {
                this.visible = false
                if (val) {
                    this.$refs.dataTable.loadTableData('reload')
                }
            },

            add() {
                this.visible = true
                this.title = '申请课程'
                this.defaultFormData = {}
            },




            loadTableData(filter, callback) {
                let courseID = JSON.parse(getCookie("courseID") || '{}');
                this.searchForm.courseId = courseID.courseID
               // console.log(this.searchForm)
                filter = {
                    ...filter,
                    ...this.searchForm
                }
                pagestudent(filter).then(res => {
                    this.total = res.data.total
                    // console.log(this.total)
                    let tableData = {
                        ...res.data,
                        data: res.data.records

                    }
                    callback(tableData)

                })
            },
            selection(val) {
                this.multipleSelection = val;
            },
            search() {
                this.$refs.dataTable.loadTableData('reload')
            },
            reset() {
                this.$refs.searchForm.resetFields()
                this.$refs.dataTable.loadTableData('reload')
            },


        }
    };
</script>
